#include<bits/stdc++.h>
using namespace std;
const int N = 100001;

int a[N],b[N];
int ap=0,bp=0;
int x,l,r;

int main(){
	while(cin>>x){
		if(ap==0||x<=a[ap-1]){
			a[ap++]=x;
		}
		else{
			l=0; r=ap-1;
			while(l<r-1){
				int mid = (r-l)/2+l;
				if(x<=a[mid]) l=mid+1;
				else r=mid;
			}
			if(x>a[l]) a[l]=x;
			else a[r]=x; 
		}
		
		if(bp==0||x>b[bp-1]){
			b[bp++]=x;
		}
		else{
			l=0; r=bp-1;
			while(l<r-1){
				int mid=(r-l)/2+l;
				if(b[mid]<x) l=mid+1;
				else r=mid;
			}
			if(x<=b[l]) b[l]=x;
			else b[r]=x;
		}
	}
	printf("%d\n%d\n",ap,bp);
	return 0;
}